﻿using M_Ingredient.API.Application.Command.IngredientCommand;
using M_Ingredient.Repository.Interface;
using MediatR;

namespace M_Ingredient.API.Application.CommandHandler.IngredientCommandHandler
{
    public class IngredientCreateCommandHandler : IRequestHandler<IngredientCreateCommand, int>
    {
        protected readonly IIngredientRepository ingredientRepository;

        public IngredientCreateCommandHandler(IIngredientRepository ingredientRepository)
        {
            this.ingredientRepository = ingredientRepository;
        }

        public Task<int> Handle(IngredientCreateCommand request, CancellationToken cancellationToken)
        {
            return ingredientRepository.AddAsync(request);
           
        }
    }
}
